package com.panopset.gui.container;

import javax.swing.JMenuItem;

public class StorageMenuItem<T> extends JMenuItem
    implements Comparable<StorageMenuItem<T>> {
    public final T itemStorage;
    public StorageMenuItem(T value) {
        super(value.toString());
        itemStorage = value;
    }

    @Override
    public int compareTo(StorageMenuItem<T> o) {
        return getText().compareTo(o.getText());
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof StorageMenuItem<?>)) {
            return false;
        }
        return getText().equals(((StorageMenuItem<?>) obj).getText());
    }

    @Override
    public int hashCode() {
        return getText().hashCode();
    }

    private static final long serialVersionUID = 1L;
}
